package com.l024.framework;

import android.content.Context;

import com.l024.framework.bmob.BmobManager;
import com.l024.framework.cloud.CloudManager;
import com.l024.framework.utils.Logutils;
import com.l024.framework.utils.SpUtils;

import org.litepal.LitePal;

/**
 * @author wu_ming_zhi_bei
 * @date 2020/2/12 10:25
 */
public class Framework {
    private volatile static  Framework framework;

    private Framework(){

    }

    public static Framework getFramework(){
        if(framework==null){
            synchronized (Framework.class){
                if(framework==null){
                    framework = new Framework();
                }
            }
        }
        return framework;
    }

    /**
     * 初始化框架 Model
     *
     * @param mContext
     */
    public void initFramework(Context mContext) {
        Logutils.i("initFramework");
        //初始化SP缓存
        SpUtils.getInstance().initSp(mContext);
        //初始化bmob
        BmobManager.getInstance().initBmob(mContext);
        //初始化融云
        CloudManager.getInstance().initCloud(mContext);
        //初始化litePal数据库
        LitePal.initialize(mContext);
        //MapManager.getInstance().initMap(mContext);
        //WindowHelper.getInstance().initWindow(mContext);
        //CrashReport.initCrashReport(mContext, BUGLY_KEY, BuildConfig.LOG_DEBUG);
        //ZXingLibrary.initDisplayOpinion(mContext);
        //NotificationHelper.getInstance().createChannel(mContext);
        //KeyWordManager.getInstance().initManager(mContext);
        //
        ////全局捕获RxJava异常
        //RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
        //    @Override
        //    public void accept(Throwable throwable) throws Exception {
        //        LogUtils.e("RxJava：" + throwable.toString());
        //    }
        //});
    }
}
